#!/usr/bin/env python
# -*- coding: utf-8 -*-

#===----------------------------------------------------------------------===##
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
#===----------------------------------------------------------------------===##

import os
import sys

config_map = {}

def map_config(source_dir, site_config):
    global config_map
    source_dir = os.path.realpath(source_dir)
    source_dir = os.path.normcase(source_dir)
    site_config = os.path.normpath(site_config)
    config_map[source_dir] = site_config

# Make sure we can find the lit package.
sys.path.insert(0, os.path.join("@LLVM_SOURCE_DIR@", 'utils', 'lit'))

@STL_LIT_CONFIG_MAP@

builtin_parameters= {}
builtin_parameters['config_map'] = config_map

def assert_same_platform_for_build_and_test():
    build_platform = '$ENV{Platform}'
    test_platform = os.getenv('Platform', default='')
    if build_platform != '' and test_platform != '' and build_platform != test_platform:
        exit(f'Target platform mismatch: the STL was built for {build_platform} but tested for {test_platform}.')

if __name__=='__main__':
    assert_same_platform_for_build_and_test()
    from lit.main import main
    main(builtin_parameters)
